from typing import List
# https://leetcode-cn.com/problems/count-items-matching-a-rule/submissions/
# 1773. 统计匹配检索规则的物品数量
class Solution:
    def countMatches(self, items: List[List[str]], ruleKey: str, ruleValue: str) -> int:
        ret=0
        if ruleKey=="color":
            indexNum=1
        elif ruleKey=="type":
            indexNum=0
        else:
            indexNum=2
        for  i in items:
            if i[indexNum]==ruleValue:
                ret+=1
        return ret
if __name__ == '__main__':
    items = [["phone", "blue", "pixel"], ["computer", "silver", "lenovo"],
             ["phone", "gold", "iphone"]]
    ruleKey = "color"
    ruleValue = "silver"

    Solution().countMatches(items,ruleKey,ruleValue)